tree-wide: Switch to autoptr for GOptionContext
authorColin Walters <walters@verbum.org>
Thu, 8 Dec 2016 15:32:09 +0000 (10:32 -0500)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 8 Dec 2016 16:48:20 +0000 (16:48 +0000)
We were leaking in a few places that I noticed in an ASAN run.  Also,
this was one of the last non-autoptr cleanup sections we have in
`out:` cleanup sections, making us a lot closer to a potential
full-tree rewrite to `return FALSE`.

Closes: #624
Approved by: jlebon

48 files changed:
src/ostree/ot-admin-builtin-cleanup.c
src/ostree/ot-admin-builtin-deploy.c
src/ostree/ot-admin-builtin-diff.c
src/ostree/ot-admin-builtin-init-fs.c
src/ostree/ot-admin-builtin-instutil.c
src/ostree/ot-admin-builtin-os-init.c
src/ostree/ot-admin-builtin-set-origin.c
src/ostree/ot-admin-builtin-status.c
src/ostree/ot-admin-builtin-switch.c
src/ostree/ot-admin-builtin-undeploy.c
src/ostree/ot-admin-builtin-unlock.c
src/ostree/ot-admin-builtin-upgrade.c
src/ostree/ot-admin-instutil-builtin-grub2-generate.c
src/ostree/ot-admin-instutil-builtin-selinux-ensure-labeled.c
src/ostree/ot-admin-instutil-builtin-set-kargs.c
src/ostree/ot-builtin-admin.c
src/ostree/ot-builtin-cat.c
src/ostree/ot-builtin-checkout.c
src/ostree/ot-builtin-checksum.c
src/ostree/ot-builtin-commit.c
src/ostree/ot-builtin-config.c
src/ostree/ot-builtin-diff.c
src/ostree/ot-builtin-export.c
src/ostree/ot-builtin-fsck.c
src/ostree/ot-builtin-gpg-sign.c
src/ostree/ot-builtin-init.c
src/ostree/ot-builtin-log.c
src/ostree/ot-builtin-ls.c
src/ostree/ot-builtin-prune.c
src/ostree/ot-builtin-pull-local.c
src/ostree/ot-builtin-pull.c
src/ostree/ot-builtin-refs.c
src/ostree/ot-builtin-remote.c
src/ostree/ot-builtin-reset.c
src/ostree/ot-builtin-rev-parse.c
src/ostree/ot-builtin-show.c
src/ostree/ot-builtin-static-delta.c
src/ostree/ot-builtin-summary.c
src/ostree/ot-main.c
src/ostree/ot-remote-builtin-add-cookie.c
src/ostree/ot-remote-builtin-add.c
src/ostree/ot-remote-builtin-delete-cookie.c
src/ostree/ot-remote-builtin-delete.c
src/ostree/ot-remote-builtin-gpg-import.c
src/ostree/ot-remote-builtin-list-cookies.c
src/ostree/ot-remote-builtin-list.c
src/ostree/ot-remote-builtin-refs.c
src/ostree/ot-remote-builtin-summary.c

index 7a76c14b568cc1a75e497167895df69ae0f51c7d..a6f74e387ecc59e7451e1aee584d3edd757238ff 100644 (file)
@@ -36,7 +36,7 @@ static GOptionEntry options[] = {
 gboolean
 ot_admin_builtin_cleanup (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeSysroot *sysroot = NULL;
   gboolean ret = FALSE;
 
@@ -55,7 +55,5 @@ ot_admin_builtin_cleanup (int argc, char **argv, GCancellable *cancellable, GErr
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 3039cf0de7e62459a5ce42bfd320add479d01e9f..e59bec8ef8c7c074d79ee971baa0b0dc5878e0e4 100644 (file)
@@ -54,7 +54,7 @@ ot_admin_builtin_deploy (int argc, char **argv, GCancellable *cancellable, GErro
 {
   gboolean ret = FALSE;
   const char *refspec;
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeSysroot *sysroot = NULL;
   GKeyFile *origin = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
@@ -173,7 +173,5 @@ ot_admin_builtin_deploy (int argc, char **argv, GCancellable *cancellable, GErro
  out:
   if (origin)
     g_key_file_unref (origin);
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 85a820ac9368e639bdc4ae75887dfb4dffde6a48..2615f24c97e72aae713a5824d9b928983393c6ae 100644 (file)
@@ -39,7 +39,7 @@ static GOptionEntry options[] = {
 gboolean
 ot_admin_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeSysroot *sysroot = NULL;
   gboolean ret = FALSE;
   glnx_unref_object OstreeDeployment *deployment = NULL;
@@ -95,7 +95,5 @@ ot_admin_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 1f12255393b3d74846577bd7455b70b289ba612c..9c08630db85d5503bfffa1aa7ad34ef0ad439d0d 100644 (file)
@@ -36,7 +36,7 @@ static GOptionEntry options[] = {
 gboolean
 ot_admin_builtin_init_fs (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeSysroot *sysroot = NULL;
   gboolean ret = FALSE;
   glnx_fd_close int root_dfd = -1;
@@ -88,7 +88,5 @@ ot_admin_builtin_init_fs (int argc, char **argv, GCancellable *cancellable, GErr
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 88894a6af0be5225511a6d4911493c8e47a4accd..f27316a3968112cb29494e3fabb2f8ef79c7511c 100644 (file)
@@ -109,7 +109,7 @@ ot_admin_builtin_instutil (int argc, char **argv, GCancellable *cancellable, GEr
 
   if (!subcommand->name)
     {
-      GOptionContext *context;
+      g_autoptr(GOptionContext) context = NULL;
       g_autofree char *help;
 
       context = ostree_admin_instutil_option_context_new_with_commands ();
@@ -134,8 +134,6 @@ ot_admin_builtin_instutil (int argc, char **argv, GCancellable *cancellable, GEr
       help = g_option_context_get_help (context, FALSE, NULL);
       g_printerr ("%s", help);
 
-      g_option_context_free (context);
-
       goto out;
     }
 
index fbb049493ea68a380ee26ff0296c6b32c55933a7..cb95bebd12ddc2515a17021f08f2962875de245d 100644 (file)
@@ -36,7 +36,7 @@ static GOptionEntry options[] = {
 gboolean
 ot_admin_builtin_os_init (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeSysroot *sysroot = NULL;
   gboolean ret = FALSE;
   const char *osname = NULL;
@@ -66,7 +66,5 @@ ot_admin_builtin_os_init (int argc, char **argv, GCancellable *cancellable, GErr
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 2b6866cc5e884a35cc84d4855b017c0228fc00a6..a814d9d5efe7b916504aa5dac2217866616675b9 100644 (file)
@@ -44,7 +44,7 @@ gboolean
 ot_admin_builtin_set_origin (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   const char *remotename = NULL;
   const char *url = NULL;
   const char *branch = NULL;
@@ -144,7 +144,5 @@ ot_admin_builtin_set_origin (int argc, char **argv, GCancellable *cancellable, G
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 2550bceade56ee4724254847a29eb85124e88d3f..940e5df0f975c0ef60c4fe70416bcd6619bea904 100644 (file)
@@ -83,7 +83,7 @@ out:
 gboolean
 ot_admin_builtin_status (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeSysroot *sysroot = NULL;
   gboolean ret = FALSE;
   glnx_unref_object OstreeRepo *repo = NULL;
@@ -193,7 +193,5 @@ ot_admin_builtin_status (int argc, char **argv, GCancellable *cancellable, GErro
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 485e6cd41ccb424bcd3837fed82d82a77d4d280c..877cbe96ba72001adead9e19a7b96a9ce2bf0d22 100644 (file)
@@ -43,7 +43,7 @@ gboolean
 ot_admin_builtin_switch (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeSysroot *sysroot = NULL;
   const char *new_provided_refspec = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
@@ -162,7 +162,5 @@ ot_admin_builtin_switch (int argc, char **argv, GCancellable *cancellable, GErro
  out:
   if (new_origin)
     g_key_file_unref (new_origin);
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index dd41950eca2fa29d1334b74235f2feeea90abc7d..cc86ee43061e0a202511bbf00810a329b72cbc10 100644 (file)
@@ -36,7 +36,7 @@ gboolean
 ot_admin_builtin_undeploy (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeSysroot *sysroot = NULL;
   const char *deploy_index_str;
   int deploy_index;
@@ -91,7 +91,5 @@ ot_admin_builtin_undeploy (int argc, char **argv, GCancellable *cancellable, GEr
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index a178937780e2b98eca8cf07ff4e593d20d885e2e..0f22d0a615d61dd0cec47bd32d1c18e85e47a193 100644 (file)
@@ -42,7 +42,7 @@ gboolean
 ot_admin_builtin_unlock (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeSysroot *sysroot = NULL;
   OstreeDeployment *booted_deployment = NULL;
   OstreeDeploymentUnlockedState target_state;
@@ -95,7 +95,5 @@ ot_admin_builtin_unlock (int argc, char **argv, GCancellable *cancellable, GErro
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 2ad74fc686ba7ac07da2a149649932c5d0ef896a..394b339a9bfc1fdf4a6e21481c1fcdcae203a2c1 100644 (file)
@@ -49,7 +49,7 @@ gboolean
 ot_admin_builtin_upgrade (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeSysroot *sysroot = NULL;
   glnx_unref_object OstreeSysrootUpgrader *upgrader = NULL;
   g_autoptr(GKeyFile) origin = NULL;
@@ -140,7 +140,5 @@ ot_admin_builtin_upgrade (int argc, char **argv, GCancellable *cancellable, GErr
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 7d837ff4c3c164d0a790859fc9d2fceadb54496f..4b8b581b5eeb779008c613bfba585f25ec10a12f 100644 (file)
@@ -38,7 +38,7 @@ ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, GCancellable *c
 {
   gboolean ret = FALSE;
   guint bootversion;
-  GOptionContext *context = NULL;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeSysroot *sysroot = NULL;
 
   context = g_option_context_new ("[BOOTVERSION] - generate GRUB2 configuration from given BLS entries");
@@ -76,7 +76,5 @@ ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, GCancellable *c
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 692a2623a8b9cb4481e82a3bccfa79786f34fd30..424c764508c79dafb40308cd5be8e97d646826ef 100644 (file)
@@ -188,7 +188,7 @@ ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, GCancel
   glnx_unref_object OstreeSePolicy *sepolicy = NULL;
   g_autoptr(GPtrArray) deployments = NULL;
   OstreeDeployment *first_deployment;
-  GOptionContext *context = NULL;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeSysroot *sysroot = NULL;
   g_autoptr(GFile) deployment_path = NULL;
 
@@ -241,7 +241,5 @@ ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, GCancel
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index c51fc4d265e34904c6ba3de357575937a1f78c94..ad792a3aacabdb80645c219a92effeaf3fac9106 100644 (file)
@@ -50,7 +50,7 @@ ot_admin_instutil_builtin_set_kargs (int argc, char **argv, GCancellable *cancel
   guint i;
   g_autoptr(GPtrArray) deployments = NULL;
   OstreeDeployment *first_deployment = NULL;
-  GOptionContext *context = NULL;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeSysroot *sysroot = NULL;
   __attribute__((cleanup(_ostree_kernel_args_cleanup))) OstreeKernelArgs *kargs = NULL;
 
@@ -115,7 +115,5 @@ ot_admin_instutil_builtin_set_kargs (int argc, char **argv, GCancellable *cancel
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 7e7b04b577be73b720b5434f2be641e00757c6f9..4760e532b1218fbf8c7ecbc69ff5108ed1e8db13 100644 (file)
@@ -124,7 +124,7 @@ ostree_builtin_admin (int argc, char **argv, GCancellable *cancellable, GError *
 
   if (!subcommand->name)
     {
-      GOptionContext *context;
+      g_autoptr(GOptionContext) context = NULL;
       g_autofree char *help;
 
       context = ostree_admin_option_context_new_with_commands ();
@@ -149,8 +149,6 @@ ostree_builtin_admin (int argc, char **argv, GCancellable *cancellable, GError *
       help = g_option_context_get_help (context, FALSE, NULL);
       g_printerr ("%s", help);
 
-      g_option_context_free (context);
-
       goto out;
     }
 
index e258f3f7eef74a54a2cb2aa097c7a0f45e651e7f..a784afe11c33a35d02d51d04bba900c18a24ebde 100644 (file)
@@ -61,7 +61,7 @@ cat_one_file (GFile         *f,
 gboolean
 ostree_builtin_cat (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   gboolean ret = FALSE;
   int i;
@@ -98,7 +98,5 @@ ostree_builtin_cat (int argc, char **argv, GCancellable *cancellable, GError **e
  
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 21e568b2886dd8e83c19a42b0ff32f2595f4fc6f..95172f8b1c46bdf3837d0c2dd6f9e07df8aa777c 100644 (file)
@@ -230,7 +230,7 @@ process_many_checkouts (OstreeRepo         *repo,
 gboolean
 ostree_builtin_checkout (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   gboolean ret = FALSE;
   const char *commit;
@@ -281,7 +281,5 @@ ostree_builtin_checkout (int argc, char **argv, GCancellable *cancellable, GErro
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 09697c88de0ec685565038a1088f5c89f5666e6f..540b02a1778c03d4dfb640fff665add0e38308fc 100644 (file)
@@ -58,7 +58,7 @@ on_checksum_received (GObject    *obj,
 gboolean
 ostree_builtin_checksum (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   gboolean ret = FALSE;
   g_autoptr(GFile) f = NULL;
   AsyncChecksumData data = { 0, };
@@ -87,7 +87,5 @@ ostree_builtin_checksum (int argc, char **argv, GCancellable *cancellable, GErro
  out:
   if (data.loop)
     g_main_loop_unref (data.loop);
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index fa8298173600006c39e7292aa51c80eefc8e5792..d3b634f97ea97d73a492c2b4694d29b19dd72407 100644 (file)
@@ -331,7 +331,7 @@ parse_keyvalue_strings (char             **strings,
 gboolean
 ostree_builtin_commit (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   gboolean ret = FALSE;
   gboolean skip_commit = FALSE;
@@ -672,8 +672,6 @@ ostree_builtin_commit (int argc, char **argv, GCancellable *cancellable, GError
  out:
   if (repo)
     ostree_repo_abort_transaction (repo, cancellable, NULL);
-  if (context)
-    g_option_context_free (context);
   if (modifier)
     ostree_repo_commit_modifier_unref (modifier);
   return ret;
index 75ccbeb07b3f0fc1211d9d209b70fea367e5d881..0d8f7b77b0b4cf7850521a759a9a8e176bfb4a23 100644 (file)
@@ -55,7 +55,7 @@ split_key_string (const char   *k,
 gboolean
 ostree_builtin_config (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context = NULL;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   gboolean ret = FALSE;
   const char *op;
@@ -133,7 +133,5 @@ ostree_builtin_config (int argc, char **argv, GCancellable *cancellable, GError
  out:
   if (config)
     g_key_file_free (config);
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index a23ed83f371dfb85d3e5191bec77dbc126640c38..963a8b7ccf1e5c60e949ef0627301df2c8815469 100644 (file)
@@ -121,7 +121,7 @@ gboolean
 ostree_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   const char *src;
   const char *target;
@@ -224,7 +224,5 @@ ostree_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError **
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index b0bb40fa28927318499a10865d95c61829684539..f3cdfbe03cfc356186312222bd09a84be0c0f9b9 100644 (file)
@@ -60,7 +60,7 @@ propagate_libarchive_error (GError      **error,
 gboolean
 ostree_builtin_export (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   gboolean ret = FALSE;
   const char *rev;
@@ -155,7 +155,5 @@ ostree_builtin_export (int argc, char **argv, GCancellable *cancellable, GError
   
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 090b44a09dbc5470477c442c810e270d13d98e67..2f154cffeca8341c2166bb84a31bd289f7496285 100644 (file)
@@ -240,7 +240,7 @@ gboolean
 ostree_builtin_fsck (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   GHashTableIter hash_iter;
   gpointer key, value;
@@ -355,7 +355,5 @@ ostree_builtin_fsck (int argc, char **argv, GCancellable *cancellable, GError **
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 221e2004758de1697d15594b194fc191f5968562..c19ec6822d698f8b2e1b08a660f5956ad9ac6fd7 100644 (file)
@@ -197,7 +197,7 @@ out:
 gboolean
 ostree_builtin_gpg_sign (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   g_autofree char *resolved_commit = NULL;
   const char *commit;
@@ -254,8 +254,5 @@ ostree_builtin_gpg_sign (int argc, char **argv, GCancellable *cancellable, GErro
   ret = TRUE;
 
 out:
-  if (context)
-    g_option_context_free (context);
-
   return ret;
 }
index a250b793488b6b1f0e86d412e0974bb5629b8a3f..8180a8aea566981bfe3844ad2d241a8fccfe415c 100644 (file)
@@ -36,7 +36,7 @@ static GOptionEntry options[] = {
 gboolean
 ostree_builtin_init (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context = NULL;
+  g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeRepo) repo = NULL;
   gboolean ret = FALSE;
   OstreeRepoMode mode;
@@ -54,7 +54,5 @@ ostree_builtin_init (int argc, char **argv, GCancellable *cancellable, GError **
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index ab0f1f0d6c862eaa464ec4f74ff2e7200db3935d..ca1cdc68bec988dd94b50e5b0d6a35e6ed26b1b8 100644 (file)
@@ -81,7 +81,7 @@ ostree_builtin_log (int           argc,
                     GCancellable *cancellable,
                     GError      **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   gboolean ret = FALSE;
   const char *rev;
@@ -111,7 +111,5 @@ ostree_builtin_log (int           argc,
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index ab63c8bb60210b5e3b791ab74f9b81e7557ba8b5..3abeb5c4946cf550b2f3a499916afaf63671e286 100644 (file)
@@ -242,7 +242,7 @@ print_one_argument (OstreeRepo   *repo,
 gboolean
 ostree_builtin_ls (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   gboolean ret = FALSE;
   const char *rev;
@@ -280,7 +280,5 @@ ostree_builtin_ls (int argc, char **argv, GCancellable *cancellable, GError **er
   
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 393ba3798bcbcddd7285e5c1560a0e200af0b256..d226c84b580b8ab37756d94c8c8694b998083a0a 100644 (file)
@@ -169,7 +169,7 @@ gboolean
 ostree_builtin_prune (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   g_autofree char *formatted_freed_size = NULL;
   OstreeRepoPruneFlags pruneflags = 0;
@@ -235,7 +235,5 @@ ostree_builtin_prune (int argc, char **argv, GCancellable *cancellable, GError *
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 58a653ffd925bc042494ed7b8956fd4ab2e99391..28717b854251ddc0b939ea69ffc95d974485a2b7 100644 (file)
@@ -53,7 +53,7 @@ gboolean
 ostree_builtin_pull_local (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   int i;
   const char *src_repo_arg;
@@ -174,8 +174,6 @@ ostree_builtin_pull_local (int argc, char **argv, GCancellable *cancellable, GEr
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   if (repo)
     ostree_repo_abort_transaction (repo, cancellable, NULL);
   return ret;
index 8fa510023312d271429ab19393c4ce7d160ba28e..f370ca018ace3c07ddb4279170ee7b1a66560b85 100644 (file)
@@ -109,7 +109,7 @@ dry_run_console_progress_changed (OstreeAsyncProgress *progress,
 gboolean
 ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   gboolean ret = FALSE;
   g_autofree char *remote = NULL;
@@ -308,7 +308,5 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **
  out:
   if (signal_handler_id > 0)
     g_signal_handler_disconnect (repo, signal_handler_id);
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 017b0c74b37f46cc259a3b32ae4ee4bf865ad735..c7ea9a951764a776a2d4f3bfadf6984a8a01ecb9 100644 (file)
@@ -130,7 +130,7 @@ gboolean
 ostree_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   int i;
 
@@ -172,8 +172,6 @@ ostree_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError **
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   if (repo)
     ostree_repo_abort_transaction (repo, cancellable, NULL);
   return ret;
index 57c3ae090582c4970bdd5b2c30863c62d2a87fbf..4f01cac2b1779b704d9585c546ab185dc51b039f 100644 (file)
@@ -113,7 +113,7 @@ ostree_builtin_remote (int argc, char **argv, GCancellable *cancellable, GError
 
   if (!subcommand->name)
     {
-      GOptionContext *context;
+      g_autoptr(GOptionContext) context = NULL;
       g_autofree char *help;
 
       context = remote_option_context_new_with_commands ();
@@ -137,8 +137,6 @@ ostree_builtin_remote (int argc, char **argv, GCancellable *cancellable, GError
       help = g_option_context_get_help (context, FALSE, NULL);
       g_printerr ("%s", help);
 
-      g_option_context_free (context);
-
       goto out;
     }
 
index 9468ae7889ab26e81e56ea7129316881aaa49a13..cab579aeb510680808508235924f7d842b40ae14 100644 (file)
@@ -37,7 +37,7 @@ ostree_builtin_reset (int           argc,
                       GCancellable *cancellable,
                       GError      **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   g_autoptr(GHashTable) known_refs = NULL;
   gboolean ret = FALSE;
@@ -83,8 +83,6 @@ ostree_builtin_reset (int           argc,
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   if (repo)
     ostree_repo_abort_transaction (repo, cancellable, NULL);
   return ret;
index fb68d4ac6cecabbf05df7dc128444d8a662bd55b..bedcc79d0d2653041d278d98f5783edaf75bef2d 100644 (file)
@@ -34,7 +34,7 @@ static GOptionEntry options[] = {
 gboolean
 ostree_builtin_rev_parse (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   gboolean ret = FALSE;
   const char *rev = "master";
@@ -63,7 +63,5 @@ ostree_builtin_rev_parse (int argc, char **argv, GCancellable *cancellable, GErr
  
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index a9c1fbbc654d6a2588e5791976af95de3c3d6452..6c45002a8df1b0208cc18a43cb87c1080b9b33f1 100644 (file)
@@ -252,7 +252,7 @@ print_if_found (OstreeRepo        *repo,
 gboolean
 ostree_builtin_show (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   gboolean ret = FALSE;
   const char *rev;
@@ -361,7 +361,5 @@ ostree_builtin_show (int argc, char **argv, GCancellable *cancellable, GError **
  
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index e1c3bb48711c1b4e18aee2d404e37eeb3ae53bbb..c8843a652e03e4e77976a3d933206ea9c72474cc 100644 (file)
@@ -110,7 +110,7 @@ ot_static_delta_builtin_list (int argc, char **argv, GCancellable *cancellable,
   gboolean ret = FALSE;
   g_autoptr(GPtrArray) delta_names = NULL;
   guint i;
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
 
   context = g_option_context_new ("LIST - list static delta files");
@@ -135,8 +135,6 @@ ot_static_delta_builtin_list (int argc, char **argv, GCancellable *cancellable,
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
 
@@ -144,7 +142,7 @@ static gboolean
 ot_static_delta_builtin_show (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   const char *delta_id = NULL;
 
@@ -167,8 +165,6 @@ ot_static_delta_builtin_show (int argc, char **argv, GCancellable *cancellable,
       
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
 
@@ -176,7 +172,7 @@ static gboolean
 ot_static_delta_builtin_delete (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   const char *delta_id = NULL;
 
@@ -199,8 +195,6 @@ ot_static_delta_builtin_delete (int argc, char **argv, GCancellable *cancellable
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
 
@@ -209,7 +203,7 @@ static gboolean
 ot_static_delta_builtin_generate (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
 
   context = g_option_context_new ("GENERATE [TO] - Generate static delta files");
@@ -348,8 +342,6 @@ ot_static_delta_builtin_generate (int argc, char **argv, GCancellable *cancellab
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
 
@@ -359,7 +351,7 @@ ot_static_delta_builtin_apply_offline (int argc, char **argv, GCancellable *canc
   gboolean ret = FALSE;
   const char *patharg;
   g_autoptr(GFile) path = NULL;
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
 
   context = g_option_context_new ("APPLY-OFFLINE - Apply static delta file");
@@ -390,8 +382,6 @@ ot_static_delta_builtin_apply_offline (int argc, char **argv, GCancellable *canc
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
 
index 2ff1c965b4c7abdedf5cca9e987c73cb17394751..04ba84e813633f989fe7fc58e5749a835eb93737 100644 (file)
@@ -40,7 +40,7 @@ gboolean
 ostree_builtin_summary (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
 
   context = g_option_context_new ("Manage summary metadata");
@@ -75,7 +75,5 @@ ostree_builtin_summary (int argc, char **argv, GCancellable *cancellable, GError
 
   ret = TRUE;
  out:
-  if (context)
-    g_option_context_free (context);
   return ret;
 }
index 0d0587f2872f5dc01433da01617227a0ff43d987..fb782275a9558a53dfbc0f78268f55a58aa08def 100644 (file)
@@ -83,7 +83,7 @@ int
 ostree_usage (OstreeCommand *commands,
               gboolean is_error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   g_autofree char *help;
 
   context = ostree_option_context_new_with_commands (commands);
@@ -97,8 +97,6 @@ ostree_usage (OstreeCommand *commands,
   else
     g_print ("%s", help);
 
-  g_option_context_free (context);
-
   return (is_error ? 1 : 0);
 }
 
@@ -172,7 +170,7 @@ ostree_run (int    argc,
 
   if (!command->fn)
     {
-      GOptionContext *context;
+      g_autoptr(GOptionContext) context = NULL;
       g_autofree char *help;
 
       context = ostree_option_context_new_with_commands (commands);
@@ -196,8 +194,6 @@ ostree_run (int    argc,
       help = g_option_context_get_help (context, FALSE, NULL);
       g_printerr ("%s", help);
 
-      g_option_context_free (context);
-
       goto out;
     }
 
index f1657bb890716e46b815e68bc5096dac1c3de963..509c9c7a5b28f16fd35b384bab72efa7b243d51b 100644 (file)
@@ -37,7 +37,7 @@ static GOptionEntry option_entries[] = {
 gboolean
 ot_remote_builtin_add_cookie (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   const char *remote_name;
   const char *domain;
@@ -80,7 +80,5 @@ ot_remote_builtin_add_cookie (int argc, char **argv, GCancellable *cancellable,
   /* jar takes ownership of cookie */
   soup_cookie_jar_add_cookie (jar, cookie);
 
-  if (context)
-    g_option_context_free (context);
   return TRUE;
 }
index 9d275cb5f93153d5b9f7db591085692f909b793b..93c989f92590ea16d785ad9b725a4c4e96f285ac 100644 (file)
@@ -44,7 +44,7 @@ static GOptionEntry option_entries[] = {
 gboolean
 ot_remote_builtin_add (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   const char *remote_name;
   const char *remote_url;
@@ -149,7 +149,5 @@ ot_remote_builtin_add (int argc, char **argv, GCancellable *cancellable, GError
 
   ret = TRUE;
  out:
-  g_option_context_free (context);
-
   return ret;
 }
index df65b277b5183b2f406fc6a40d5f3eab28aff720..d974dd8da5cc15d03394d5973f093499ee3cfbb7 100644 (file)
@@ -37,7 +37,7 @@ static GOptionEntry option_entries[] = {
 gboolean
 ot_remote_builtin_delete_cookie (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   const char *remote_name;
   const char *domain;
@@ -92,7 +92,5 @@ ot_remote_builtin_delete_cookie (int argc, char **argv, GCancellable *cancellabl
   if (!found)
     g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Cookie not found in jar");
 
-  if (context)
-    g_option_context_free (context);
   return found;
 }
index caa5cf8f041bdef6a7cf504a27e2485ea87e9692..8a4dd5f3bf3b0c4487dd57463bcaba13d7008ba6 100644 (file)
@@ -35,7 +35,7 @@ static GOptionEntry option_entries[] = {
 gboolean
 ot_remote_builtin_delete (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   const char *remote_name;
   gboolean ret = FALSE;
@@ -63,7 +63,5 @@ ot_remote_builtin_delete (int argc, char **argv, GCancellable *cancellable, GErr
 
   ret = TRUE;
  out:
-  g_option_context_free (context);
-
   return ret;
 }
index 4d2ad50509d174e03f3ec5c1090fe6aa2a8e1535..d1db06d0b9fa90f53ccdc7c2f85c9cd1b342d6f0 100644 (file)
@@ -93,7 +93,7 @@ out:
 gboolean
 ot_remote_builtin_gpg_import (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   g_autoptr(GInputStream) source_stream = NULL;
   const char *remote_name;
@@ -136,7 +136,5 @@ ot_remote_builtin_gpg_import (int argc, char **argv, GCancellable *cancellable,
   ret = TRUE;
 
  out:
-  g_option_context_free (context);
-
   return ret;
 }
index 5ccc5d8dd5d8e849a1acfaa4bbee1adf525133ff..1865fb0761e82b2b3a50f460652d04edf51bb8cd 100644 (file)
@@ -37,7 +37,7 @@ static GOptionEntry option_entries[] = {
 gboolean
 ot_remote_builtin_list_cookies (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   const char *remote_name;
   g_autofree char *jar_path = NULL;
index c42c44ba3a5b37df579bc430c23fa79da8e98e64..faf8d8ad3e97a19a7914bf02c93bd34be28c9574 100644 (file)
@@ -33,7 +33,7 @@ static GOptionEntry option_entries[] = {
 gboolean
 ot_remote_builtin_list (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   g_auto(GStrv) remotes = NULL;
   guint ii, n_remotes = 0;
@@ -73,7 +73,5 @@ ot_remote_builtin_list (int argc, char **argv, GCancellable *cancellable, GError
   ret = TRUE;
 
  out:
-  g_option_context_free (context);
-
   return ret;
 }
index 4317c45fb6cee907760cc96dfae21e80540c68be..9e74291263e380bb1f85e86efee6422f530d288a 100644 (file)
@@ -35,7 +35,7 @@ static GOptionEntry option_entries[] = {
 gboolean
 ot_remote_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   const char *remote_name;
   gboolean ret = FALSE;
@@ -78,9 +78,6 @@ ot_remote_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError
     }
 
   ret = TRUE;
-
 out:
-  g_option_context_free (context);
-
   return ret;
 }
index 4659dd4dea411de9d49688cbf1b8af47389256f8..39321b53ffd8862ffdbddb1492281e5bd8674cc4 100644 (file)
@@ -39,7 +39,7 @@ static GOptionEntry option_entries[] = {
 gboolean
 ot_remote_builtin_summary (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
-  GOptionContext *context;
+  g_autoptr(GOptionContext) context = NULL;
   glnx_unref_object OstreeRepo *repo = NULL;
   const char *remote_name;
   g_autoptr(GBytes) summary_bytes = NULL;
@@ -120,9 +120,6 @@ ot_remote_builtin_summary (int argc, char **argv, GCancellable *cancellable, GEr
     }
 
   ret = TRUE;
-
 out:
-  g_option_context_free (context);
-
   return ret;
 }